#pragma data_seg("Myseg")
#include "index.h"

char seg[1000][256] = {};
int count1 = 0;
volatile int HeapAllocNum = 0;
#pragma data_seg()
#pragma comment(linker, "/section:<Myseg,RWS")

std::mutex mtx;
extern "C" __declspec(dllexport)void ChangeSeg(LPCSTR str) {
	mtx.lock();
	count1++;
	if (count1 >= 1000) {
		count1--;
	}
	else {
		strcpy_s(seg[count1], str);
	}
	mtx.unlock();
}

extern "C" __declspec(dllexport)void GetSeg(char *str, int i) {
	mtx.lock();
	strcpy_s(str, 256, seg[i]);
	mtx.unlock();
}

extern "C" __declspec(dllexport)void GetNum(int& num) {
	mtx.lock();
	num = count1;
	mtx.unlock();
}

extern "C" __declspec(dllexport)void GetHeapAllocNum(int& num) {
	num = HeapAllocNum;
}
